/*********************************************************
          File Name:base.h
          Author: Abby Cin
          Mail: abbytsing@gmail.com
          Created Time: Sat 19 Sep 2015 07:03:01 PM CST
**********************************************************/

#ifndef BASE_H_
#define BASE_H_

#include <iostream>
#include <memory>

class Human
{
        private:
                std::string name;
        protected:
                int age;
        public:
                Human(std::string n=std::string("null"), int a=-1) :
                        name(n), age(a) {}

                Human(const char *n = "null", int a = -1) :
                        name(std::string(n)), age(a) {}

                Human(Human &h)
                {
                        name = h.name;
                        age = h.age;
                }

                virtual ~Human() = default;

                Human &operator=(Human h)
                {
                        if(this != &h)
                        {
                                name = h.name;
                                age = h.age;
                        }
                        return *this;
                }

                void update(std::string n, int a)
                {
                        name = n;
                        age = a;
                }

                virtual std::string getname() const
                {
                        return name;
                }

                int getage()
                {
                        return age;
                }
};

void print_info(Human h)
{
        std::cout << "name: " << h.getname() << "\t"
                << "age: " << h.getage() << std::endl;
}

/*
void print_info(Human &h)
{
        std::cout << "name: " << h.getname() << "\t"
                << "age: " << h.getage() << std::endl;
}
*/
void print_info(std::shared_ptr<Human> h)
{
        std::cout << "name: " << h->getname() << "\t"
                << "age: " << h->getage() << std::endl;
}

#endif
